//
// Created by 匡涂上青 on 2021/7/5.
//

#ifndef KGL_CAMERA_H
#define KGL_CAMERA_H

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>

namespace kgl {

    struct Transform;

    class Camera {
    public:
        explicit Camera(Transform& transform);

        glm::mat4 get_view_mat() const;

        virtual glm::mat4 get_projection_mat() const = 0;

    protected:
        Transform& transform;
    };

    class OrthographicCamera : public Camera {
    public:
        OrthographicCamera(Transform& transform, const glm::vec2 &size, float zoom, float _near, float _far);

        glm::mat4 get_projection_mat() const override;

    private:
        glm::vec2 size;
        float _near, _far;
    };

    class PerspectiveCamera : public Camera {
    public:
        PerspectiveCamera(Transform& transform, float fov, float aspect, float _near, float _far);

        glm::mat4 get_projection_mat() const override;

        void SetFov(float fov) { this->fov = fov; }

    private:
        float fov, aspect, _near, _far;
    };

}

#endif //KGL_CAMERA_H
